<?php



namespace App\Services\Member\Models;
use App\Services\Business\Models\Base;



class UserRedpacket extends Base
{


    protected $table = 'user_redpacket';


    protected $fillable = [
        'receiver_id','user_id','parts','total','reward_value','blessing_words','step','claim_count','claim_count'
    ];

    protected $appends = [
        'redpacket'
    ];



    public function receiver()
    {
        return $this->belongsTo(User::class, 'receiver_id');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }



    public function getRedpacketAttribute()
    {
        $redpackets = explode("|",$this->reward_value);
        return   $redpackets[0]?? 0;
    }






}
